package com.gjs.intranet.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gjs.intranet.mapper.LibraryBookMapper;
import com.gjs.intranet.pojo.dto.LibraryBookQueryDTO;
import com.gjs.intranet.pojo.entity.LibraryBook;
import com.gjs.intranet.service.ILibraryBookService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 图书表 服务实现类
 * </p>
 *
 * @author JC_Ho
 * @since 2022-04-11
 */
@Service
public class LibraryBookServiceImpl extends ServiceImpl<LibraryBookMapper, LibraryBook> implements ILibraryBookService {
    @Override
    public Wrapper<LibraryBook> buildWrapper(LibraryBookQueryDTO queryDTO){
        LambdaQueryWrapper<LibraryBook> wrapper = new LambdaQueryWrapper<>();

        wrapper.eq(queryDTO.getId() != null && queryDTO.getId() > 0,LibraryBook::getId,queryDTO.getId());
        wrapper.eq(!StringUtils.isEmpty(queryDTO.getIsbn()),LibraryBook::getIsbn,queryDTO.getIsbn());

        return wrapper;
    }
}
